<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <input type="text" value="" placeholder="原文">
    <button id="btn">转换</button>
    <input type="text" value="" placeholder="密文" disabled>
    <script>
        btn.onclick = function () {
            var inp1 = document.getElementsByTagName('input')[0]
            var inp2 = document.getElementsByTagName('input')[1]
            var num1 = inp1.value - 0
            var a1 = num1 % 10
            var b2 = parseInt(num1 % 100 / 10)
            var c3 = parseInt(num1 % 1000 / 100)
            var d4 = parseInt(num1 / 1000)
            var a4 = String((a1 + 5) % 10)
            var b3 = String((b2 + 5) % 10)
            var c2 = String((c3 + 5) % 10)
            var d1 = String((d4 + 5) % 10)
            var res = Number(a4 + b3 + c2 + d1)
            inp2.value = res
        }
    </script>
</body>

</html>